<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
>

    
        <f:view>
            <h:form enctype="multipart/form-data" >
                <p:panel id="panel" header="Edit User" style="width:auto">
                <p:column>
                        <h:commandLink id="preview1" value="" ><img src="#{userControl.user.avatar}" height="100" width="70" /></h:commandLink>
                </p:column>
                <h:panelGrid columns="2">
                    
                    <h:outputLabel value="UserName:" for="userName" />
                     <p:inputText id="userName" value="#{userControl.user.userName}" label="UserName">
                           <f:validateLength minimum="1"/>
                           <p:message id="msu" for="userName" display="UserName is not be empty "/>
                     </p:inputText>
                    
                    <h:outputLabel value="PassWord:" for="passWord" />
                    <h:inputText id="passWord" value="#{userControl.user.passWord}" title="PassWord" />
                   
                    <h:outputLabel value="Sex:" for="sex" />
                    <p:selectOneRadio id="options" value="#{userControl.user.sex}">  
                           <f:selectItem itemLabel="Male" itemValue="true" />  
                           <f:selectItem itemLabel="Female" itemValue="false" />    
                    </p:selectOneRadio>
                    
                   <h:outputLabel value="FullName:" for="fullName" />
                   <p:inputText id="fullName" value="#{userControl.user.fullName}" label="FullName" required="true">
                            <f:validateLength minimum="6"/>
                            <p:message id="msfn" for="fullName" display="FullName is not be empty "/>
                   </p:inputText>
                   
                    <h:outputLabel value="Birthday:" for="birthday" /> 
                    <p:calendar id="dob" binding="#{userControl.dob}" mindate="01/01/1952" value="#{userControl.user.birthday}" navigator="true" required="true" requiredMessage="Choose your Birthday"/> 
                    
                    <h:outputLabel value="Phone" for="phone"/>
                            <p:inputMask id="phone" value="#{userControl.user.phone}" mask="999-999-9999" validatorMessage="Phone is not valid">
                                <p:message for="phone"/>
                            </p:inputMask>
                    
                    <h:outputLabel value="Address:" for="address" />
                            <p:inputText id="address" value="#{userControl.user.address}" title="Address" required="true">
                                <f:validateLength minimum="1"/>
                                <p:message id="msad" for="address" display="Address must be minium 5 char "/>
                            </p:inputText>
                    
                    <h:outputLabel value="Email:" for="email" />
                            <p:inputText id="email" value="#{userControl.user.email}" required="true" label="Email" validatorMessage="#{userControl.user.email} is not valid">
                                <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
                                <p:message for="email" />
                            </p:inputText>                    
                    
                    <h:outputLabel value="DepartmentName:" for="departmentName" />
                            <p:selectOneMenu value="#{userControl.user.departmentName}">
                                <f:selectItem itemLabel="Select One" itemValue=""/>
                                <f:selectItem itemLabel="Manager" itemValue="Manager"/>
                                <f:selectItem itemLabel="Maketing" itemValue="MaKeting"/>
                                <f:selectItem itemLabel="IT" itemValue="IT"/>
                                <f:selectItem itemLabel="Accounting" itemValue="Accounting"/>
                                <f:selectItem itemLabel="Sales" itemValue="Sales"/>
                                <f:selectItem itemLabel="Protection" itemValue="Protection"/>
                                <p:message for="departmentName" display="Please choose Department!!!"/>
                            </p:selectOneMenu>
                    
                    <h:outputLabel value="Avatar:" for="avatar" />
                    <p:fileUpload mode="advanced"  sizeLimit="1000000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" auto="true"  fileUploadListener="#{userControl.handleFileUploadEditProfile}" />  
                    <h:outputLabel value="Avatar:" for="preview" />
                    <h:commandLink id="preview" value="" ><img src="#{userControl.user.avatar}" height="100" width="70" /></h:commandLink>
                    
                    <p:commandButton value="Update" actionListener="#{userControl.updateprofileuser()}" update="panel" icon="ui-icon-disk"/>
                    <p:commandButton value="Reset" type="reset"/>
                </h:panelGrid>
                </p:panel>
            </h:form>
        </f:view>

  

</ui:composition>
